<script type="text/javascript">
$(function(){
	var pg = App.message.recipientEdit.ui, pp = pg.params,
		title = pg.children('.navi').seek('title');

	title.text("添加收件人队列");
	var frm = {
		code: pg.seek('code'),
		name: pg.seek('name'),
		catalog: pg.seek('catalog'),
		xml: pg.seek('xml')
	};

	function getValues(){
		return {
			id: pp.id,
			code: frm.code.val(),
			name: frm.name.val(),
			catalog: frm.catalog.val(),
			xml: frm.xml.val()
		};
	}

	function setValues(o){
		pp.id = o.id;
		frm.code.val(o.code);
		frm.name.val(o.name);
		frm.catalog.val(o.catalog);
		frm.xml.val(o.xml);
	}

// 	function validate1(p){
// 		var x2 = App.validate2, v = App.base.validation, m = pg.find('.msg').html('');
// 		var vd = true
// 			&& x2(v.admin.name, frm.catalog)
// 			&& x2(v.svc.version, frm.code)
// 			&& x2(v.svc.name, frm.name);
// 		return vd;
// 	}

// 	pg.find('input').blur(function(e){
// 		var pms = getValues();
// 		if (!validate1(pms, e.currentTarget.name)) {
// 			return;
// 		}
// 	});

	pg.seek('back').click(function(){
		App.show({
			ctx: 'message',
			action: 'queueIndex',
			params: {}
		}, $.noop, pg.parent());
	});

	pg.seek('ok').click(function(){
		var pms = getValues();
// 		if (!validate1(pms)) {
// 			return;
// 		}
		$.post(App.ctx + '/recipient/queue/save.do', pms, function(rs){
			var ro = mac.eval(rs);
			if (ro.success) {
				App.show({
					ctx : 'message',
					action : 'queueIndex',
					params : {}
				}, $.noop, pg.parent());
			} else {
				pg.seek('msg').html(mac.msg(ro.data, ro.params));
			}
		});
		return false;
	});

	if (pp.id) {
		title.text("修改收件人队列");
		$.get(App.ctx + '/recipient/queue/get.do', {
			id: pp.id
		}, function(rs) {
			var ro = mac.eval(rs);
			if (ro.success) {
				setValues(ro.data);
			} else {
				pg.seek('msg').html(mac.msg(ro.data, ro.params));
			}
		}); 
	}
});
</script>
<div class="navi">
	<span class="a" name="back">队列与主题</span>&gt;&gt;
	<span name="title">收件人修改</span>
</div>
<div class="form">
	<div class="item">
		<span class="label">所属系统：</span>
		<input class="input" type="text" name="catalog" placeholder="请填入所属系统" />
		<span class="msg">*</span>
		<div class="clear"></div>
	</div>
	<div class="item">
		<span class="label">队列编号：</span>
		<input class="input" type="text" name="code" placeholder="请填入队列编号" />
		<span class="msg">*</span>
		<div class="clear"></div>
	</div>
	<div class="item">
		<span class="label">队列名称：</span>
		<input class="input" type="text" name="name" placeholder="请填入队列名称" />
		<div class="clear"></div>
	</div>
	<div class="item">
		<span class="label">XML配置：</span>
		<textarea name="xml" ></textarea>
		<div class="clear"></div>
	</div>
	<div class="item">
		<span class="label"></span>
		<span class="msg" name="msg"></span>
	</div>
	<div class="bottom">
		<button name="ok">提交</button>
	</div>
</div>